
#include "LinearCurve.h"

LinearCurve::LinearCurve() : Curve()
{
	m_fMinX = 0;
	m_fMaxX = 1;
	m_fMinY = 0;
	m_fMaxY = 1;
}

LinearCurve::~LinearCurve()
{
}

void LinearCurve::setBounds(float _fMinX, float _fMaxX, float _fMinY, float _fMaxY)
{
	m_fMinX = _fMinX;
	m_fMaxX = _fMaxX;
	m_fMinY = _fMinY;
	m_fMaxY = _fMaxY;
}

float LinearCurve::computeF(float x)
{
	if(x <= m_fMinX) return m_fMinY;
	if(x >= m_fMaxX) return m_fMaxY;
	float fPerc = (x - m_fMinX) / (m_fMaxX - m_fMinX);
	return m_fMinY + fPerc * (m_fMaxY - m_fMinY);
}
